#!/bin/bash

kill -SIGTERM "$1"
echo "kill -SIGTERM $1"

n=60
for (( i=0; i<n; i++)); do
  echo "$i/$n Waiting for process $1 to terminate..."
  sleep 1
  if ! ps -p "$1" > /dev/null; then
    echo "Process $1 terminated."
    exit 0
  fi
done

echo "Process $1 did not terminated, sending SIGKILL..."
kill -SIGKILL "$1"